import React from 'react'
import { Card, Button, Table, Divider, Row, Col, Modal, Form, Input } from 'antd'
import DescriptionList from 'components/DescriptionList'
import styles from './index.less'
import {
  balanceChangeType,
  balanceChangeReason,
  balanceChangeStatus
} from 'utils/enumConfig'
import moment from 'moment'
import { LwjDownload } from 'components'

const FormItem = Form.Item

const ViewModal = ({
                     currentItem, distributorItem, dispatch, ...viewModalVisible
                   }) => {
  const {Description} = DescriptionList
  console.log(currentItem)
  const formItemLayout = {
    labelCol: {
      xs: {span: 8, offset: 0},
      sm: {span: 8, offset: 0},
    },
    wrapperCol: {
      xs: {span: 8, offset: 0},
      sm: {span: 8, offset: 0},
    },
  }

  const voucherHandler = () => {
    switch (currentItem.reason) {
      case 'MORE_RECEIVING_REFUND':
        return '收款单'
      case 'WITHDRAW_DEPOSIT':
        return '支付凭证号'
      default:
        return '合同号'
    }
  }

  /** @namespace currentItem.des */
  /** @namespace currentItem.contractChangeReason */
  /** @namespace currentItem.provinceName */
  /** @namespace currentItem.cityName */
  /** @namespace currentItem.districtName */
  /** @namespace currentItem.checkDes */
  /** @namespace currentItem.changeAmount */
  /** @namespace currentItem.changedAmount */
  /** @namespace currentItem.salesDistributorName */
  /** @namespace currentItem.distributorName */
  return (
    <div>
      <Modal {...viewModalVisible} footer = {null}>
        <Card className={styles.card} bordered={false}>
          <DescriptionList size="large"
                           title="审核金额变更"
                           style={{marginBottom: 32}}>
            <Description term="门店名称">{currentItem.distributorName}</Description>
            <Description term="变更类型">{balanceChangeType[(currentItem.type)]}</Description>
            <Description term="变更金额">{Math.abs(currentItem.changingAmount)}</Description>
            <Description term="申请人">{currentItem.userName}</Description>
            <Description term="申请时间">{moment(currentItem.createTime).format('YYYY-MM-DD HH:mm:ss')}</Description>
            <Description term="附件">{<LwjDownload title={'点击下载'}
                                                   targetUrl={currentItem.attachment || ''}/>}</Description>
            <Description term="变更原因">{balanceChangeReason[(currentItem.reason)]}</Description>
            <Description term="审核人">{currentItem.auditorName}</Description>
            <Description term="审核时间">{moment(currentItem.auditTime).format('YYYY-MM-DD HH:mm:ss')}</Description>
            <Description term={voucherHandler()}>{currentItem.reasonKeywords}</Description>
            {!_.isEmpty(currentItem.remark) && <Description term="备注">{currentItem.remark}</Description>}
            {!_.isEmpty(currentItem.auditDesc) && <Description term="审核备注">{currentItem.auditDesc}</Description>}
          </DescriptionList>
        </Card>
      </Modal>
    </div>
  )
}

export default ViewModal
